package com.hlmc.spider;

import com.hlmc.dao.DS_detailDao;
import com.hlmc.entity.RankVideo;
import org.springframework.stereotype.Service;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

import javax.annotation.Resource;
@Service("rank_pipeline")
public class Rank_pipeline implements Pipeline {

    @Resource
    private DS_detailDao dtDao;

    @Override
    public void process(ResultItems resultItems, Task task) {

        RankVideo rankVideo=new RankVideo();
        String tv_p_title=resultItems.get("tv_p_title");
        String tv_v_title=resultItems.get("tv_v_title");

        rankVideo.setPtitle("tv");
        rankVideo.setVtitle(tv_v_title);
        dtDao.addRank(rankVideo);

        String dy_p_title=resultItems.get("dy_p_title");
        String dy_v_title=resultItems.get("dy_v_title");

        rankVideo.setPtitle("dy");
        rankVideo.setVtitle(dy_v_title);
        dtDao.addRank(rankVideo);

        String dm_p_title=resultItems.get("dm_p_title");
        String dm_v_title=resultItems.get("dm_v_title");

        rankVideo.setPtitle("dm");
        rankVideo.setVtitle(dm_v_title);
        dtDao.addRank(rankVideo);

        String zy_p_title=resultItems.get("zy_p_title");
        String zy_v_title=resultItems.get("zy_v_title");

        rankVideo.setPtitle("zy");
        rankVideo.setVtitle(zy_v_title);
        dtDao.addRank(rankVideo);

    }
}